package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.DateUtil;
import cn.wolfcode.trip.base.util.JSONUtil;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Getter
@Setter
public class TravelCommend extends BaseDomain{

    public static final Integer TYPE_WEEK = 1;
    public static final Integer TYPE_MONTH = 2;
    public static final Integer TYPE_STRATEGY = 3;

    private Long travelId;

    private String title;

    private String subTitle;

    private String coverUrl;
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date schedule;

    private Integer type;

    public String getTypeName(){
        String temp = "每周推荐";
        if (type==TYPE_MONTH){
            temp = "每月推荐";
        }else if (type==TYPE_STRATEGY){
            temp = "攻略推荐";
        }
        return temp;
    }

    public String getJson(){
        Map<String,Object> map = new HashMap<>();
        map.put("id",id);
        map.put("travelId",travelId);
        map.put("title",title);
        map.put("subTitle",subTitle);
        map.put("coverUrl",coverUrl);
        map.put("schedule", DateUtil.formatDate(schedule));
        map.put("type",type);
        return JSONUtil.toJSONString(map);
    }
}